package events

import "BookStack/pkg/utils"

// 书籍相关事件类型常量
const (
	// 书籍相关
	BookCreatedEventType       = "book.created"
	BookUpdatedEventType       = "book.updated"
	BookDeletedEventType       = "book.deleted"
	BookPublishedEventType     = "book.published"
	BookStatusChangedEventType = "book.status_changed"
	BookRecommendedEventType   = "book.recommended"
	BookUnrecommendedEventType = "book.unrecommended"
	BookRestoredEventType      = "book.restored"
	BookHardDeletedEventType   = "book.permanently_deleted"
	BookLikedEventType         = "book.liked"
	BookUnlikedEventType       = "book.unliked"
	BookStarredEventType       = "book.starred"
	BookUnstarredEventType     = "book.unstarred"

	// 章节相关
	ChapterCreatedEventType     = "chapter.created"
	ChapterUpdatedEventType     = "chapter.updated"
	ChapterDeletedEventType     = "chapter.deleted"
	ChapterReorderedEventType   = "chapter.reordered"
	ChapterRestoredEventType    = "chapter.restored"
	ChapterHardDeletedEventType = "chapter.permanently_deleted"

	// 回收站相关
	RecycleBinClearedEventType      = "recycle_bin.cleared"
	RecycleBinItemRestoredEventType = "recycle_bin.item_restored"
)

// BookCreatedEvent 书籍创建事件
type BookCreatedEvent struct {
	ID          uint           `json:"id"`
	Title       string         `json:"title"`
	Slug        string         `json:"slug"`
	Author      string         `json:"author"`
	Description string         `json:"description"`
	Cover       string         `json:"cover"`
	Status      int            `json:"status"`
	CreatedBy   uint           `json:"created_by"`
	CreatedAt   utils.JSONTime `json:"created_at"`
}

// BookUpdatedEvent 书籍更新事件
type BookUpdatedEvent struct {
	ID          uint           `json:"id"`
	Title       string         `json:"title"`
	Slug        string         `json:"slug"`
	Author      string         `json:"author"`
	Description string         `json:"description"`
	Cover       string         `json:"cover"`
	Status      int            `json:"status"`
	UpdatedBy   uint           `json:"updated_by"`
	UpdatedAt   utils.JSONTime `json:"updated_at"`
}

// BookStatusChangedEvent 书籍状态变更事件
type BookStatusChangedEvent struct {
	ID             uint           `json:"id"`
	Title          string         `json:"title"`
	Slug           string         `json:"slug"`
	PreviousStatus int            `json:"previous_status"`
	CurrentStatus  int            `json:"current_status"`
	ChangedBy      uint           `json:"changed_by"`
	ChangedAt      utils.JSONTime `json:"changed_at"`
}

// BookDeletedEvent 书籍删除事件（移入回收站）
type BookDeletedEvent struct {
	ID        uint           `json:"id"`
	Title     string         `json:"title"`
	Slug      string         `json:"slug"`
	DeletedBy uint           `json:"deleted_by"`
	DeletedAt utils.JSONTime `json:"deleted_at"`
}

// BookRestoredEvent 书籍从回收站恢复事件
type BookRestoredEvent struct {
	ID         uint           `json:"id"`
	Title      string         `json:"title"`
	Slug       string         `json:"slug"`
	RestoredBy uint           `json:"restored_by"`
	RestoredAt utils.JSONTime `json:"restored_at"`
}

// BookHardDeletedEvent 书籍永久删除事件
type BookHardDeletedEvent struct {
	ID            uint           `json:"id"`
	Title         string         `json:"title"`
	HardDeletedBy uint           `json:"hard_deleted_by"`
	HardDeletedAt utils.JSONTime `json:"hard_deleted_at"`
}

// BookPublishedEvent 书籍发布事件
type BookPublishedEvent struct {
	ID          uint           `json:"id"`
	Title       string         `json:"title"`
	Description string         `json:"description"`
	Cover       string         `json:"cover"`
	PublishedBy uint           `json:"published_by"`
	PublishedAt utils.JSONTime `json:"published_at"`
}

// BookRecommendStatusChangedEvent 书籍推荐状态变更事件
type BookRecommendStatusChangedEvent struct {
	ID            uint           `json:"id"`
	Title         string         `json:"title"`
	IsRecommend   bool           `json:"is_recommend"`
	RecommendedBy uint           `json:"recommended_by"`
	UpdatedAt     utils.JSONTime `json:"updated_at"`
}

// BookLikeStatusChangedEvent 书籍点赞状态变更事件
type BookLikeStatusChangedEvent struct {
	ID        uint           `json:"id"`
	Title     string         `json:"title"`
	UserID    uint           `json:"user_id"`
	IsLiked   bool           `json:"is_liked"`
	CreatedAt utils.JSONTime `json:"created_at"`
}

// BookStarStatusChangedEvent 书籍收藏状态变更事件
type BookStarStatusChangedEvent struct {
	ID        uint           `json:"id"`
	Title     string         `json:"title"`
	UserID    uint           `json:"user_id"`
	IsStarred bool           `json:"is_starred"`
	CreatedAt utils.JSONTime `json:"created_at"`
}

// ChapterCreatedEvent 章节创建事件
type ChapterCreatedEvent struct {
	ID        uint           `json:"id"`
	BookID    uint           `json:"book_id"`
	Title     string         `json:"title"`
	CreatedBy uint           `json:"created_by"`
	CreatedAt utils.JSONTime `json:"created_at"`
}

// ChapterUpdatedEvent 章节更新事件
type ChapterUpdatedEvent struct {
	ID        uint           `json:"id"`
	BookID    uint           `json:"book_id"`
	Title     string         `json:"title"`
	UpdatedBy uint           `json:"updated_by"`
	UpdatedAt utils.JSONTime `json:"updated_at"`
}

// ChapterReorderedEvent 章节重排序事件
type ChapterReorderedEvent struct {
	BookID      uint           `json:"book_id"`
	ReorderedBy uint           `json:"reordered_by"`
	ReorderedAt utils.JSONTime `json:"reordered_at"`
}

// ChapterDeletedEvent 章节删除事件
type ChapterDeletedEvent struct {
	ID        uint           `json:"id"`
	BookID    uint           `json:"book_id"`
	Title     string         `json:"title"`
	DeletedBy uint           `json:"deleted_by"`
	DeletedAt utils.JSONTime `json:"deleted_at"`
}

// ChapterRestoredEvent 章节从回收站恢复事件
type ChapterRestoredEvent struct {
	ID         uint           `json:"id"`
	BookID     uint           `json:"book_id"`
	Title      string         `json:"title"`
	RestoredBy uint           `json:"restored_by"`
	RestoredAt utils.JSONTime `json:"restored_at"`
}

// ChapterHardDeletedEvent 章节永久删除事件
type ChapterHardDeletedEvent struct {
	ID            uint           `json:"id"`
	BookID        uint           `json:"book_id"`
	Title         string         `json:"title"`
	HardDeletedBy uint           `json:"hard_deleted_by"`
	HardDeletedAt utils.JSONTime `json:"hard_deleted_at"`
}

// RecycleBinClearedEvent 回收站清空事件
type RecycleBinClearedEvent struct {
	ClearedBy uint           `json:"cleared_by"`
	ClearedAt utils.JSONTime `json:"cleared_at"`
}
